<!-- 引进图片插件 begin -->
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/js/uploadify/jquery.uploadify.min.js" ></script>
<link rel="stylesheet" charset="utf-8" type="text/css" href="__PUBLIC__/admin/js/uploadify/uploadify.css"> 
<!-- 引进图片插件 end-->
<style type="text/css">
  .bg{background: none; border:none;}
</style>

<div class="container-fluid">
  <div class="row-fluid">
    <div class="span12">
    <form role="form" id="form" action="{:U('Activity/add_research')}">    
    <div class="form-group">
      <label for="name">问卷调查的标题</label>
      <input type="text" class="form-control" placeholder="例：关于公寓绿化问题" name="title" required="required" />
   </div>
    <!-- 内容描述 -->
   <div class="form-group">
      <label for="name">描述</label>
      <input type="text" class="form-control" placeholder="描述" name="description" required="required" />
   </div>
    
    <!--  <div class="form-group">
     <label for="name">选择奖品</label>
     <select name="aid" form="form">
       <option value="0">无优惠券</option>
       <volist name="arr" id="data">
       <option value="{$data.id}">{$data.name}</option>
       </volist> 
     </select>
       </div> -->
    <div class="checkbox">
      <label>
      <volist name="arr" id="data">
       <br /><input type="checkbox" name="checkbox[]" value="{$data.id}">{$data.name}
       </volist> 
      </label>
   </div>


  <div class="form-group">
     <div id="feng">
      <label for="name">封面照片<span style="color: red;">(*双击图片删除,只能有一张图片)</span></label>
      <input type="file" class="form-control" id="upload" placeholder="图片上传"> <br />
      <input type="hidden" name="cover" id="img">
      <div id="view" style="height:200px;">
        
      </div>
   </div>
    </div>


    <!-- 问卷调查的状态 -->
 <div class="form-group">
     <label for="name">是否开启</label>
      <div class="radio">
        <label>
          <input type="radio" name="state"  value="0" checked>
         关闭
        </label>
      </div>
      <div class="radio">
        <label>
          <input type="radio" name="state"  value="1">
         开启
        </label>
    </div>
</div>
    <button type="submit" class="btn btn-default">提交</button>
</form>
    </div>
  </div>
</div>
<script language="javascript">
//图片删除
  function delimg(a){
  var data={data:a.id};
  url="{:U('WxContent/delimg')}";
  $.post(url, data,function(c){   
    if(c.s){
    alert("删除成功");
    var el = document.getElementById(''+c.id+''); 
      el.parentNode.removeChild(el); 
    }else{
    alert("图片不存在，删除失败");
     var el = document.getElementById(''+c.id+''); 
    el.parentNode.removeChild(el); 
    }
  });
  }
//图片上传
$(function(){
  $("#upload").uploadify({
        'height'        : 30,
        'width'         : 90, 
    'buttonClass'   :'bg', 
    'queueSizeLimit': 6,    
        'buttonText'    :'<button type="submit" class="btn btn-primary "><span class="glyphicon glyphicon-plus">选择图片</span><tton>',
        'swf'           : '__PUBLIC__/admin/js/uploadify/uploadify.swf',
        'uploader'      : "{:U('WxContent/upload')}",
        'auto'          : true,
        'multi'         : true,      
        'fileTypeExts'  : '*.jpg;*.jpge;*.gif;*.png',
        'fileSizeLimit' : '2MB', 
        'onUploadSuccess':function(file,data,response){
             var obj = eval('('+data+')');         
       if(obj.s){
  $('#view').append('<a href="javascript:void(0);"  ondblclick="delimg(this)" id="'+obj.d+'.'+obj.c+'"><div style="float: left;width:120px;"class="'+obj.d+'"><img style="height:120px; width: 120px;" src="__PUBLIC__/upload/image/'+obj.d+'.'+obj.c+'"/><span style=" width: 120px;  height:40px; line-height: 20px; ">'+obj.d+'.'+obj.c+'</span></div></a>');
        var a=$("#img").val(obj.d+'.'+obj.c);
        //alert(a);
        $('#view').fadeIn();        
       }    
        }
    });
});
</script>